//
//  UserSortPreference.swift
//  hello
//
//  Created by 赵康 on 2025/4/15.
//
import Vapor
import Fluent

// 用户排序偏好模型
final class UserSortPreference: Model, Content, @unchecked Sendable {
	static var schema: String { SchemaEnum.userSortPreferences.rawValue }
	
	@ID(key: .id)
	var id: UUID?
	
	@Parent(key: FieldKeys.user)
	var user: User
	
	@Parent(key: FieldKeys.folder)
	var folder: Folder
	
	@Field(key: FieldKeys.sortOrder)
	var sortOrder: String
	
	@Timestamp(key: FieldKeys.createdAt, on: .create)
	var createdAt: Date?
	
	@Timestamp(key: FieldKeys.updatedAt, on: .update)
	var updatedAt: Date?
	
	init() { }
	
	init(id: UUID? = nil, userID: User.IDValue, folderID: Folder.IDValue, sortOrder: String) {
		self.id = id
		self.$user.id = userID
		self.$folder.id = folderID
		self.sortOrder = sortOrder
	}
}

  // 保存排序偏好请求模型
struct SaveSortPreferenceRequest: Content {
  let sortOrder: String
}
